import requests
import subprocess
from functools import partial

subprocess.Popen = partial(subprocess.Popen, encoding='utf-8')
import execjs
import requests
import time
with open('调试.js', 'r', encoding='utf-8') as f:
    js = f.read()

js_com = execjs.compile(js)

cookies = {
    'RK': 'H7Eg6rjGOJ',
    'ptcz': '3e83bf8a3497288018241dd7ff76531d86e281529cd0a8be978545f9e58fb54a',
    'qq_domain_video_guid_verify': '5dcceb6613b9108d',
    '_qimei_uuid42': '18b060c2d3310058c008e937051b908882a90d7405',
    'pgv_pvid': '9276625719',
    '_qimei_q36': '',
    '_qimei_h38': 'e06dff59c008e937051b908802000007118b06',
    '_clck': '16znpzo|1|frh|0',
    '_qimei_fingerprint': '53323f732d1bdf478e2a5b58951c5207',
    'fqm_pvqid': 'eb39ad3d-e83b-441f-90a2-3783d56cd7b0',
    'fqm_sessionid': 'bdbc2709-3a41-43b3-9f3c-d40fa8933848',
    'pgv_info': 'ssid=s1534812496',
    'ts_refer': 'www.bing.com/',
    'ts_uid': '4710545720',
    '_qpsvr_localtk': '0.018818201191145523',
    'ptui_loginuin': '1913738160',
    'login_type': '1',
    'qqmusic_key': 'Q_H_L_63k3NyidGM7nCVfXzs3tzQdhVFZgXpOJ4hZ1uKUJFMxbBK7o58Z0kKkn7nWbwQTMWydYKBjufxoH598ahWWOAJg',
    'psrf_qqaccess_token': '5EED19925A495613ABACFFF5E88C7B41',
    'psrf_access_token_expiresAt': '1735695605',
    'euin': 'oKE5oiSiNe6son**',
    'psrf_musickey_createtime': '1735090806',
    'psrf_qqopenid': 'DF602D6327693D59289020AB7D48A473',
    'psrf_qqunionid': '56D1C69DC35A0D0CC0C0855005897A89',
    'psrf_qqrefresh_token': '837F1D2271DA92E761A6D26A0303FC37',
    'music_ignore_pskey': '202306271436Hn@vBj',
    'tmeLoginType': '2',
    'wxopenid': '',
    'wxunionid': '',
    'qm_keyst': 'Q_H_L_63k3NyidGM7nCVfXzs3tzQdhVFZgXpOJ4hZ1uKUJFMxbBK7o58Z0kKkn7nWbwQTMWydYKBjufxoH598ahWWOAJg',
    'uin': '1913738160',
    'wxrefresh_token': '',
    'ts_last': 'y.qq.com/n/ryqq/songDetail/004Z8Ihr0JIu5s',
}

headers = {
    'accept': 'application/json',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,ru;q=0.7',
    'cache-control': 'no-cache',
    'content-type': 'application/x-www-form-urlencoded',
    # 'cookie': 'RK=H7Eg6rjGOJ; ptcz=3e83bf8a3497288018241dd7ff76531d86e281529cd0a8be978545f9e58fb54a; qq_domain_video_guid_verify=5dcceb6613b9108d; _qimei_uuid42=18b060c2d3310058c008e937051b908882a90d7405; pgv_pvid=9276625719; _qimei_q36=; _qimei_h38=e06dff59c008e937051b908802000007118b06; _clck=16znpzo|1|frh|0; _qimei_fingerprint=53323f732d1bdf478e2a5b58951c5207; fqm_pvqid=eb39ad3d-e83b-441f-90a2-3783d56cd7b0; fqm_sessionid=bdbc2709-3a41-43b3-9f3c-d40fa8933848; pgv_info=ssid=s1534812496; ts_refer=www.bing.com/; ts_uid=4710545720; _qpsvr_localtk=0.018818201191145523; ptui_loginuin=1913738160; login_type=1; qqmusic_key=Q_H_L_63k3NyidGM7nCVfXzs3tzQdhVFZgXpOJ4hZ1uKUJFMxbBK7o58Z0kKkn7nWbwQTMWydYKBjufxoH598ahWWOAJg; psrf_qqaccess_token=5EED19925A495613ABACFFF5E88C7B41; psrf_access_token_expiresAt=1735695605; euin=oKE5oiSiNe6son**; psrf_musickey_createtime=1735090806; psrf_qqopenid=DF602D6327693D59289020AB7D48A473; psrf_qqunionid=56D1C69DC35A0D0CC0C0855005897A89; psrf_qqrefresh_token=837F1D2271DA92E761A6D26A0303FC37; music_ignore_pskey=202306271436Hn@vBj; tmeLoginType=2; wxopenid=; wxunionid=; qm_keyst=Q_H_L_63k3NyidGM7nCVfXzs3tzQdhVFZgXpOJ4hZ1uKUJFMxbBK7o58Z0kKkn7nWbwQTMWydYKBjufxoH598ahWWOAJg; uin=1913738160; wxrefresh_token=; ts_last=y.qq.com/n/ryqq/songDetail/004Z8Ihr0JIu5s',
    'origin': 'https://y.qq.com',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://y.qq.com/',
    'sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0',
}
data = '{"comm":{"cv":4747474,"ct":24,"format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"yqq.json","needNewCode":1,"uin":1913738160,"g_tk_new_20200303":1407374010,"g_tk":1407374010},"req_1":{"module":"music.musicsearch.HotkeyService","method":"GetHotkeyForQQMusicMobile","param":{"searchid":"25086659214240155","remoteplace":"txt.yqq.top","from":"yqqweb"}},"req_2":{"module":"music.musicsearch.HotkeyService","method":"GetHotkeyForQQMusicMobile","param":{"searchid":"22080431215143324","remoteplace":"txt.yqq.top","from":"yqqweb"}},"req_3":{"module":"yqq.WhiteListServer","method":"Pass","param":{}},"req_4":{"module":"music.paycenterapi.LoginStateVerificationApi","method":"GetChargeAccount","param":{"appid":"mlive"}},"req_5":{"module":"MessageCenter.MessageCenterServer","method":"GetMessage","param":{"uin":"1913738160","red_dot":[{"msg_type":1}]}},"req_6":{"module":"GlobalComment.GlobalCommentMessageReadServer","method":"GetMessage","param":{"uin":"1913738160","page_num":0,"page_size":1,"last_msg_id":"","type":0}},"req_7":{"module":"music.musicsearch.HotkeyService","method":"GetHotkeyForQQMusicMobile","param":{"searchid":"29044510232209836","remoteplace":"txt.yqq.top","from":"yqqweb"}},"req_8":{"module":"music.musicsearch.HotkeyService","method":"GetHotkeyForQQMusicMobile","param":{"searchid":"34079938479974828","remoteplace":"txt.yqq.top","from":"yqqweb"}},"req_9":{"module":"yqq.WhiteListServer","method":"Pass","param":{}},"req_10":{"module":"music.paycenterapi.LoginStateVerificationApi","method":"GetChargeAccount","param":{"appid":"mlive"}},"req_11":{"module":"MessageCenter.MessageCenterServer","method":"GetMessage","param":{"uin":"1913738160","red_dot":[{"msg_type":1}]}},"req_12":{"module":"GlobalComment.GlobalCommentMessageReadServer","method":"GetMessage","param":{"uin":"1913738160","page_num":0,"page_size":1,"last_msg_id":"","type":0}}}';

sign = js_com.call('getSign', data)
print(sign)

params = {
    '_': str(int(time.time()*1000)),
    # 'sign': 'zzc70b2b92ymp5l7nqbvchnvpsfgs4ysjvy8bb63246a',
    'sign': sign,
}



response = requests.post('https://u6.y.qq.com/cgi-bin/musics.fcg', params=params, cookies=cookies, headers=headers, data=data)
print(response.status_code)
print(response.text)